package org.extremengine.common;

import org.extremengine.shape.Shape;

/**
 * 表示地形的对象
 * @author yuxing
 * 
 */
public class Terrain implements Collidable{
	
	private String name;

	private double friction;

	// Default is 50% speed after collide.
	private double elasticity = 0.5;

	// 
	private Shape shape;

	public Terrain(String name, double friction, double elasticity, Shape shape) {
		super();
		this.name = name;
		this.friction = friction;
		this.setElasticity(elasticity);
		this.shape = shape;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public double getFriction() {
		return friction;
	}

	public void setFriction(double friction) {
		this.friction = friction;
	}

	public double getElasticity() {
		return elasticity;
	}

	public void setElasticity(double elasticity) {
		if(elasticity > 1) {
			this.elasticity = 1;
		}
		else if(elasticity < 0) {
			this.elasticity = 0;
		}
		else {
			this.elasticity = elasticity;
		}
	}

	public Shape getShape() {
		return shape;
	}

	public void setShape(Shape shape) {
		this.shape = shape;
	}

	@Override
	public String toString() {
		return name + "[" + shape + "]";
	}

}
